import * as actionTypes from './actionTypes';
import axios from 'axios';
import { fromJS } from 'immutable';

const giveStore = (searchList,totlePage) => ({
    type:actionTypes.GIVE_STORE,
    searchList:fromJS(searchList),
    totlePage:totlePage,
})

export const changeInput = (value) => ({
    type:actionTypes.HANDLE_INPUT,
    value,
})
export const getListArea = () => {
    return (dispath) => {
        axios.get('/header.json')
        .then( (response) => {
            let totlePage = Math.ceil(response.data.searchList.length/10);
            dispath(giveStore(response.data.searchList,totlePage));
        })
        .catch( (error) => {
            console.log(error);
        });
    }
}
export const OnMouseEenter = () =>{
    return {
        type:actionTypes.MOUSE_ENTER
    }
}
export const OnMouseLeave = () =>{
    return {
        type:actionTypes.MOUSE_LEAVE
    }
}
export const ChangePage = (value) =>{
    return {
        type:actionTypes.CHANGE_PAGE,
        value
    }
}